📚 SAP Business One SDK Help

Adding a user table
See Also
Private Sub AddUserTable()

'//****************************************************************************
'// The UserTablesMD represents a meta-data object that allows
'// to add\remove tables, change a table name and so on.
'//****************************************************************************

    Dim oUserTablesMD As SAPbobsCOM.UserTablesMD

'//****************************************************************************
'// In any meta-data operation there should be no other object "alive"
'// but the meta-data object, otherwise the operation will fail.
'// This restriction is intended to prevent collisions
'//****************************************************************************

    '// The meta-data object must be initialized with a
    '// regular UserTables object
    Set oUserTablesMD = oCompany.GetBusinessObject(oUserTables)

    '//**************************************************
    '// When adding user tables or fields to the SAP Business One database
    '// use a prefix identifying your partner name space.
    '// This will prevent collisions between the various
    '// partners' add-ons
    '//
    '// SAP's name space prefix is "BE_"
    '//**************************************************

    '// Set the two mandatory fields
    oUserTablesMD.TableName = "BE_USER1"
    oUserTablesMD.TableDescription = "A simple user table"

    '// Add the table.
    '// An empty table is added with two default fields:
    '// 'Code' and 'Name' that serve as the key

    oUserTablesMD.Add

End Sub